#include "..\\include\Lib_Clara.h"
#include "..\\include\Dir.h"
#include "gui.h"

MyBOOK * myBook;

int TerminateElf(void * ,BOOK* book)
{
  FreeBook(book);
  return(1);
}

typedef struct
{
  BOOK * book;
}MSG;

int ShowAuthorInfo(void *mess ,BOOK* book)
{
  MSG * msg = (MSG*)mess;
  MessageBox(0x6fFFFFFF,STR("Hello Wordl!\n\nExample elf.."),0, 1 ,5000,msg->book);
  return(1);
}

const PAGE_MSG HW_PageEvents[]@ "DYN_PAGE" ={
  ELF_TERMINATE_EVENT , TerminateElf,
  ELF_SHOW_INFO_EVENT  , ShowAuthorInfo,
  0,0
};

PAGE_DESC base_page ={"HW_BasePage",0,HW_PageEvents};


void elf_exit(void)

{
  kill_data(&ELF_BEGIN, (void(*)(void*))mfree_adr());
}

void onCloseHWBook(BOOK * book)
{
  if (book)
  {
    SUBPROC(elf_exit);
  }
}

MyBOOK * CreateHWBook()
{
  myBook= new MyBOOK;  
  CreateBook(myBook,onCloseHWBook,&base_page,"Example",-1,0);
  return(myBook);
}

int main (void)
{
  CreateHWBook();  
  GuiCreateGuiList(0, (BOOK *)myBook, L"Example GUI", 3); 
  /*
  void GuiCreateGuiList(void * r0, BOOK * bk, wchar_t * GUI_NAME, int ItemNumber):
  */
  return(0);
}
